package models

import "time"

// Attachment 附件表
type Attachment struct {
	ID            uint64    `gorm:"primaryKey;comment:文件ID"`
	FileName      string    `gorm:"type:varchar(200);not null;index;comment:原始文件名"`
	StorageKey    string    `gorm:"type:varchar(500);uniqueIndex;comment:云存储路径"`
	ServiceVendor string    `gorm:"type:varchar(20);not null;comment:服务商(oss/qiniu)"`
	FileHash      string    `gorm:"type:char(32);index;comment:文件MD5哈希"`
	FileSize      int64     `gorm:"comment:文件字节数"`
	MimeType      string    `gorm:"type:varchar(50);comment:MIME类型"`
	RefCount      int       `gorm:"default:0;index;comment:引用计数"`
	Status        int8      `gorm:"default:1;index;comment:状态 1有效 0待删除"`
	CreatedAt     time.Time `gorm:"autoCreateTime;index;comment:创建时间"`
	LastRefTime   time.Time `gorm:"index;comment:最后引用时间"`
	CreatorID     uint      `gorm:"index;comment:上传者ID"`
}

func (Attachment) TableName() string {
	return "attachments"
}
